package com.dr.java.day02;

/**
 * Created by rui on 2017/12/29.
 */
public class Operation3 {

    public static void main(String[] args) {
        System.out.println(Integer.toBinaryString(60));
        System.out.println(Integer.toHexString(60));

        int num = 26;
//        做了一个位运算(只取最低的4位)
        int n1 = num & 15;
        System.out.println(n1);

        // http://blog.csdn.net/java_chuck/article/details/51913605,三目运算的返回值会受到表达式的类型影响呢
//        System.out.println(n1>9 ? (char)((n1-10)+'a'): n1);

        System.out.println(change2Hex(n1));

        int temp = num >>> 4;
        int n2 = temp & 15;
        System.out.println(change2Hex(n2));

        System.out.println(false ? 'c' : 65);

    }

    private static String change2Hex(int n1) {
        if (n1 > 9) {
            return (char) ((n1 - 10) + 'a') + "";
        } else {
            return n1 + "";
        }
    }
}
